package com.feibi.study.Adapter

import android.annotation.SuppressLint
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.annotation.NonNull
import androidx.recyclerview.widget.RecyclerView
import com.feibi.study.R

class WheelAdapter(
    var context: Context,
    var menus: List<String>
) : RecyclerView.Adapter<WheelAdapter.ViewHolder?>() {
    @NonNull
    override fun onCreateViewHolder(@NonNull viewGroup: ViewGroup, i: Int): ViewHolder {
        val view: View = LayoutInflater.from(viewGroup.context)
            .inflate(R.layout.item_wheel, viewGroup, false)
        return ViewHolder(view)
    }

    override fun onBindViewHolder(@NonNull viewHolder: ViewHolder, @SuppressLint("RecyclerView") i: Int) {
        viewHolder.apply {
            tv_content.text = menus[i]
        }
    }

    override fun getItemCount(): Int {
        return menus.size
    }

    class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        val tv_content: TextView = view.findViewById(R.id.tv_content)
    }
}